package com.bosssoft.user.permission.center.serve.api;

import com.bosssoft.user.permission.center.serve.pojo.query.LoginQuery;
import com.bosssoft.user.permission.center.serve.pojo.vo.LoginVO;
import com.bosssoft.user.permission.center.serve.pojo.vo.RouteVO;
import common.data.commonresponse.CommonResponse;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * @interfaceName: LoginApi
 * @description: 前后端登录功能进行交互的api
 * @author: lanyukai
 * @date: 2024/6/11 14:36
 * @since 1.0
 **/
@Api(tags = "登录", value = "/api/v1/permission/auth")
@RequestMapping("/api/v1/permission")
@Validated
@CrossOrigin(origins = "*")
public interface LoginApi {
    /**
     * 用于进行登录校验以及用户token返回
     * @author lanyukai
     * @date 2024/06/11 19:59
     * @param loginQuery 前端传回的用户输入的登录信息
     * @return 返回用户信息token
     */
    @ApiOperation(value = "根据用户表单登录校验",notes = "校验完成后返回token")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code = -1,message = "请求失败")
    })
    @GetMapping("/auth")
    CommonResponse<LoginVO> login(@NotNull @Valid
                                 @ApiParam(value = "登录信息表单", required = true)
                                 LoginQuery loginQuery);

    /**
     * 根据token中的角色列表生成动态路由
     * @author lanyukai
     * @date 2024/06/15 11:34
     * @return 路由表信息
     */
    @ApiOperation(value = "根据token中的角色列表生成动态路由", notes = "鉴权完成后返回路由表")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "请求失败")
    })
    @GetMapping("/route")
    CommonResponse<RouteVO> createDynamicRoute();
}
